<template>
  <div class="main-database">
    <div class="page-outcome">
      <div class="page-outcome-header">
        <div class="head-title">
          <van-icon name="arrow-left" @click="ongetRouter" />
        </div>
        <div class="head-txt">
          <span>目标达成！</span><br>
          <span>恭喜你完成今日联系</span><br>
          <span class="txt-time">{{dayjs().format("MM月DD日 dddd HH:mm")}}</span>
        </div>
      </div>
      <div class="page-outcome-body">
        <div class="page-outcome-center">
          <div class="center-header">
            <van-row>
              <van-col span="8"
                >总刷题
                <p><span class="td">20</span>题</p>
              </van-col>
              <van-col span="8"
                >正确率
                <p><span class="td">{{corrects}}</span>%</p></van-col
              >
              <van-col span="8"
                >总用时
                <p><span class="td">20</span>分</p>
              </van-col>
            </van-row>
          </div>
          <div class="center-sheets">
            <div class="sheets-title">
              <p>答题卡</p>
              <span><van-icon name="circle" color="#0DA" class="th1"/>正确</span>
              <span><van-icon name="circle" color="#ff0000"  class="th2"/>错误</span>
              <span><van-icon name="circle" color="#666666" class="th3" />未答</span>
            </div>
            <div class="sheets-content">
              <p>单选题</p>
              <p>
                <template v-for="(item,index) in drillStore.contrasts" :key="item">
                    <template v-if="item===true">
                       <van-badge :content="index+1" color="#0DA" />
                    </template>
                    <template v-else-if="item===false">
                       <van-badge :content="index+1" color="#ff0000" />
                    </template>
                    <template v-else>
                       <van-badge :content="index+1" color="#666666" />
                    </template>
                </template>
              </p>
            </div>
          </div>
          <div class="center-feeter">
            <span>再练一次</span>
            <van-button @click="showShare = true"
              >立即分享</van-button
            >
            <van-share-sheet
              v-model:show="showShare"
              title="立即分享给好友"
              :options="options"
            />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default { name: "outcome" };
</script>
<script setup>
import dayjs from "dayjs";
import { ref } from "vue";
import {usedrillStore} from "../../stores/drill"
function ongetRouter() {
  window.history.back();
}


const showShare = ref(false);
const options = [
  [
    { name: "微信", icon: "wechat" },
    { name: "朋友圈", icon: "wechat-moments" },
    { name: "微博", icon: "weibo" },
    { name: "QQ", icon: "qq" },
  ],
  [
    { name: "复制链接", icon: "link" },
    { name: "分享海报", icon: "poster" },
    { name: "二维码", icon: "qrcode" },
    { name: "小程序码", icon: "weapp-qrcode" },
  ],
];

const drillStore=usedrillStore();
const total=drillStore.contrasts.filter((item)=>item===true)
const corrects=parseInt(total.length/drillStore.contrasts.length*100)
</script>
<style lang="scss" scoped>
.main-database {
  height: 100%;
  overflow-y: auto;
}
.page-outcome {
  height: 100%;
  &-header {
    width: 100%;
    height: 200px;
    background-color: orange;
    .head-title {
      height: 50px;
      line-height: 50px;
      padding-left: 20px;
      box-sizing: border-box;
      .van-icon {
        font-weight: bold;
        font-size: 20px;
        color: #fff;
      }
    }
    .head-txt{
      margin-left: 30px;
      font-size: 19px;
      color: #fff;
      font-weight: bold;
      .txt-time{
        font-size: 10px;
        margin-bottom: 10px;
        opacity: .7;
      }
    }
  }
  &-body {
    width: 100%;
    height: 100%;
  }
  &-center {
    width: 100%;
    height: 100%;
    background-color: #fff;
    margin-top: -50px;
    border: 1px solid #fff;
    border-radius: 30px;
    .center-header {
      margin-top: -30px;
      margin-left: 5%;
      height: 100px;
      width: 90%;
      background-color: #fff;
      border: 1px solid #999999;
      border-radius: 10px;
      text-align: center;
      box-sizing: border-box;
      padding: 20px;
      .td {
        color: orange;
        font-weight: bold;
        font-size: 20px;
      }
    }
    .center-sheets {
      margin: 20px;
      background-color: #fff;
      border: #ddd 1px solid;
      border-radius: 10px;
      padding: 0 10px;
      .sheets-title {
        border-bottom: 1px #ddd solid;
        padding: 0 10px 10px 10px;
        p {
          font-weight: bold;
          font-size: 14px;
        }
        span {
          font-size: 10px;
          .th1 {
            margin-left: 10px;
            background-color: #0DA;
            border-radius: 50%;
          }
          .th2 {
            margin-left: 10px;
            background-color: #f00;
            border-radius: 50%;
          }
          .th3 {
            margin-left: 10px;
            background-color: #666;
            border-radius: 50%;
          }
          
        }
      }
      .sheets-content {
        padding: 0 10px 10px 10px;

        p {
          font-weight: bold;
          font-size: 12px;
        }
        .van-badge{
            width: 30px;
            height: 30px;
            line-height: 30px;
            margin: 10px;
            font-weight: bold;
        }
      }
    }
    .center-feeter{
        margin: 10px 60px;
        display: flex;
        line-height: 40px;
        justify-content: space-between;
        span{
            font-size: 12px;
        }
        .van-button{
            border-radius: 20px;
            height: 40px;
            width: 70%;
            background-color: orange;
            color: #fff;
        }
        
    }
  }
}
</style>
